<%@page import="org.biojava.dasobert.das2.Das2Capability"%>
<%@page import="org.biojava.dasobert.das.Capabilities"%>
<%@page import="org.biojava.dasobert.dasregistry.DasSource"%>
<%@page import="java.util.List"%>

<%@page import="org.biojava.dasobert.dasregistry.Das1Validator"%>
<%@page import="org.biojava.services.das.registry.ShowLinkCapability"%>
<%@page import="org.biojava.services.das.registry.CapabilityLinkBean"%>
<%@page import="org.biojava.dasobert.dasregistry.ValidationResultLights"%>
<%@page import="org.biojava.dasobert.dasregistry.LightBean"%>
<%@page import="org.biojava.dasobert.das.CapabilityStatus"%><jsp:directive.page import="org.biojava.dasobert.dasregistry.DasSource" />
<jsp:directive.page session="true"/>
<jsp:useBean id="register" class="dasregistry.registryBean" scope="session"/>
<jsp:setProperty name="register" property="*"/>
<jsp:include page="openwindowscript.jsp" />
<script src="boxover.js"></script>
<%
String spec= request.getParameter("spec");
String[] caps   = request.getParameterValues("capabilities");
String url      = request.getParameter("dasurl");
if(!url.endsWith("/"))url=url+"/";//to account for when people haven't added a slash on the end so the href link is correct below.
String testcode = request.getParameter("testcode");
String ontology = request.getParameter("ontology");
String auto_id=request.getParameter("auto_id");

//System.out.println("querySTring="+request.getQueryString());

ValidationResultLights lights = register.validate(url,testcode,caps,ontology,auto_id);
if(lights.getErrors()!=""){
	%><h2 class="invalid">Form filling in error, please fill in the missing details:<%=lights.getErrors()%></h2><%
}else{
List<LightBean> beans=lights.getLightsLinksAndResults();
//if adding update valid capabilities in database we need to make that decision based on auto_id here
//update the database with the valid capabilities, this means updated instantly but if someone has 
			//specified different test region on the test page than is in the registry then the next round of autovalidation will overwrite any changes.
			
			
			//would need to check if source is in the database already if so update
			//otherwise don't update as someone could just be testing their private source so this is the wrong place to test!!!
			
 %> 
 
 checked DAS source: 
 
 <%if(lights.isOverAllValid()){
						%><h2><font color="green">Valid Source</font></h2><%
					}else{
						%><h2><font color="red">Not a Valid Source - some capabilities stated are not valid.</font></h2><%
					}
%>
 <%@ include file="sangertablestart.jsp" %>
<tr class="row1"> <td colspan="3">server has valid capabilities: </td>
<%
for(LightBean linkBean:beans ) {
	
	
	if(linkBean.getVisible()){
	%>
	
	<tr class=<%=linkBean.getStatus().toString().toLowerCase() %>><td ><b><%=linkBean.getCapability().toString()%></b></td>	<td><a href="javascript:openWindow('<%=linkBean.getCmd()%>','',700,700)"><img title="header=[Click] body=[to show the servers response to this command]" src=<%=linkBean.getImg() %>></a><%=linkBean.getMessageBody()  %><%=linkBean.getErrorMessage() %></td>
	</tr>
<%}
	}%>
<%@ include file="sangertableend.jsp" %>



<%
	String msg=register.getValidationMessage();
	if ( ! msg.equals("")){
	%>
<font color="red">Your source is NOT valid, please look at the error messages below.</font> Validation has become stricter. The 1.5 specifications can be found <a href="http://www.biodas.org/documents/spec.html">http://www.biodas.org/documents/spec.html</a> and here <a href="spec_1.53E.jsp">spec_1.53E.jsp</a>. 
If you think the validation is incorrect and your source is valid please email <a href="mailto:dasregistry@sanger.ac.uk">dasregistry@sanger.ac.uk</a> with the error message and the source you are trying to validate.
<pre>
Error messages during validation:
      <%=msg%>
</pre>      
	<%
	}
}//end of else statement for errors not related to capabilities
%>
<script src="boxover.js"></script>



